package com.chis.dubbo;

import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import com.chis.util.CharsetUtil;
import com.chis.util.StrUtil;

/**
 * 
 * @Description 修改密码加密
 * @Company zwx
 * @author czj
 * @version 2018年09月11日
 */
public class RSACode {

   public static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx/axd29qZio4c1lP23XVs+GB7eWsUbFgGEqrhShSF15CsC97pofKlPi2Dk5sIL2zNFkj0mBl/2Vpsv+nH8mbGdbZiGByb51Avn2J4LC2O4F2LT4kVMiQA6pmAo3ZYj7qcou2yzRqFsStL4V4GSezlUd2iY5gkrzL7fH96QeBnpQIDAQAB";
   private static String privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALH9rF3b2pmKjhzWU/bddWz4YHt5axRsWAYSquFKFIXXkKwL3umh8qU+LYOTmwgvbM0WSPSYGX/ZWmy/6cfyZsZ1tmIYHJvnUC+fYngsLY7gXYtPiRUyJADqmYCjdliPupyi7bLNGoWxK0vhXgZJ7OVR3aJjmCSvMvt8f3pB4GelAgMBAAECgYAYlvEfLmZu2+NyPHHxIvs8CLxbkpSmh6lJfX66DR/0tak4+5LaOBNrnMFw8g1y/gpL8w41LGYpcX+6knDbvLNR8E3lcf8tyfUluWy4h0dSGdfymnGmd5eVcvha6qhEqnxhP4ci05RsS7SshttniClq59r9E6QsA4VLfHoRr8dBQQJBAO5m39qu/TmazYY5O8rXY+UJVYK00Bja269XB2JAY+yS+baOaRaF+2y5ou1v42UaNsWTLWdqxfD/CODL/DHvUd0CQQC/ITOjmH2QnZW2PkYM2xO0+tljEwOiwZ+IV6BbwW0RDsMaR5VpsaqqqIGqBZfoPuM3WznQ/p0DRP9IIifFm+RpAkAfSo1zTKicGP+E8Joyg5bvBwycPVNbD87p8shbUwxKjvgLyCFu/WME4FDMTXVRXeF2iVzaSB93BGKL7vpJK5pZAkBCNc88ugOtiFmno1UC+RWPmWKbRqf4xthsE+byQkR1J0cBIJEq5yg3LF6Wto9UHgz6TTjvJHTiABHrPCHI++MZAkAQGREtOtEuyvYfUvxRYoEcW52pXbOCzBoS8MU4WjhnKg1Orb098ujK3fVwpZjjov+1/UBxWzU0k5BLpeSRUJhf";

    public static String decrypt(String password) throws Exception {

        RSA rsa = new RSA(privateKey,publicKey);

        byte[] decrypt = rsa.decryptFromBase64(password, KeyType.PrivateKey);
       return  StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8);
    }
}
